package it.gius.pe.mains;

import org.jbox2d.common.Vec2;

import it.gius.pe.Shape.BadShapeException;
import it.gius.pe.Shape.Polygon;
import it.gius.processing.gjkTest.GjkPolyPointStepToStepApplet;
import it.gius.processing.util.PAppletManager;
import it.gius.processing.util.ProcessingGraphicException;
import processing.core.PApplet;

public class GjkMainPolyPointStepToStep {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Polygon poly1 = new Polygon();

		//convex polygon
	/*	poly1.addVertex(new Vec2(20,10));
		poly1.addVertex(new Vec2(2,70));
		poly1.addVertex(new Vec2(80,90));
		poly1.addVertex(new Vec2(50,20));*/
		
		poly1.addVertex(new Vec2(32.64f, 18.22f).mul(2));
		poly1.addVertex(new Vec2(50.64f, -36.78f).mul(2));
		poly1.addVertex(new Vec2(40.64f, -16.78f).mul(2));

		
		try {
			poly1.endPolygon();
		} catch (BadShapeException e) {
			e.printStackTrace();
			System.out.println("bad shape 1");
			poly1 = null;
		}
		
		poly1.setPosition(new Vec2(100,200));
		
		//Vec2 q = new Vec2 (110,210); //punto interno
		//Vec2 q = new Vec2(190,190);
		Vec2 q = new Vec2(70,210);
		
		GjkPolyPointStepToStepApplet applet = new GjkPolyPointStepToStepApplet(poly1,q);
		
		PAppletManager manager = new PAppletManager();
		try {
			manager.startAndAddApplet(new String[]{""}, applet, PAppletManager.DISPOSE_ALL);
		} catch (ProcessingGraphicException e) {
			e.printStackTrace();
			System.exit(1);
		}

	}

}
